package com.patterns.proxy.generalProxyPlayer;

/**
 * Created by Xiao Yiyun on 2017/4/22.
 * 普通代理
 * 游戏玩家代练者实现类
 * 同样实现了游戏玩家接口
 * 因为代练者同样也是游戏玩家之一
 */
public class GamePlayerProxy implements IGamePlayer {

    //客户端直接向代理类传递代理者的名字
    //而不需要说是替哪个对象代理
    private IGamePlayer gamePlayer = null;
    public GamePlayerProxy(String name) {
        try {
            gamePlayer = new GamePlayer(this, name);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //代理登录
    public void login(String user, String pwd) {
        this.gamePlayer.login(user, pwd);
    }
    //代理打怪
    public void killBoss() {
        this.gamePlayer.killBoss();
    }
    //代理升级
    public void upGrade() {
        this.gamePlayer.upGrade();
    }
}